package org.jvnc.rfb.state;

/**
* <br><br><center><table border="1" width="80%"><hr>
* <p>
* Copyright (C) 2006-2007 by Deon Wu
* <p>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.0
* of the License, or (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU Lesser General Public License</a>
* for more details.
* <p>
* You should have received a copy of the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">
* GNU Lesser General Public License</a> along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* <hr></table></center>
* **/

import java.io.IOException;

import org.jvnc.rfb.RFBSocketClient;
import org.jvnc.rfb.event.RfbEvent;
import org.jvnc.rfb.proto.DataGram;

/**
 * RFB协议的状态机。
 * @author user
 *
 */
public interface ProtocolState {
	/**
	 * 协议的处理接口，根据当前的状态读/写消息。如果有需要上层处理的回调，将封装成为一个RfbEvent。
	 * 返回后由RFBSocketClient分发到各事件监听器中。
	 * 
	 */
	public RfbEvent process() throws IOException;
	
	
	/**
	 * 异步方式发送一个报文。
	 * @param data 需要发送的报文。
	 * @param isBlock 是否以阻塞方式发送。为false时，在新线程中发送报文。
	 * @return 发送成功返回true
	 * @throws IOException
	 */
	public boolean sendDataGram(DataGram data, boolean isBlock) throws IOException;

	/**
	 * 设置状态所属的RFBSlocket
	 * @param socket
	 */
	public void setRFBSocket(RFBSocketClient socket);
}
